package com.walle.concurrenttest.juc.lock;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author zhangjiapeng
 * @Package com.walle.concurrenttest.juc.lock
 * @Description: ${todo}
 * @date 2019/3/6 14:56
 */
public class NoFairB implements Runnable{

    private ReentrantLock lock;

    public NoFairB(ReentrantLock lock) {
        this.lock = lock;
    }

    @Override
    public void run() {
        while (true){
            lock.lock();
            try {
                System.out.println("B get Lock");
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }finally {
                lock.unlock();
            }

        }
    }
}